<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<style>
    .bootbox-close-button {
        width: 19px;
        height: 19px;
        border: none;
        cursor: pointer;
        -webkit-appearance: none;
        float: right;
        top: 4px;
        left: -5px;
        position: relative;
        background: #E9F5FF url("assets/img/nav-img/icon_close.png") no-repeat 0 0;
    }
    .tssPackageEdit .modal-dialog {
        width: 60% !important;
    }

    .tssPackageEdit .modal-body {
        padding-bottom: 0;
    }
    input[type="text"],select{
        height: 30px!important;
        border-radius: 5px!important;
    }
</style>
<div class="col-lg-12 col-sm-12 col-xs-12">
    <div class="widget">
        <div class="modal-header">
            <button type="button" class="bootbox-close-button" data-dismiss="modal" aria-hidden="true"></button>
            <h4 class="modal-title">${(editModel=='add')?string('新增亲子课时包','编辑亲子课时包')}</h4>
        </div>
        <div class="modal-body" style="padding-top: 0px!important">
            <div class="row">
                <form class="editForm" action="${saveUrl}" method="post" responseType="JSON" role="form"
                      id="editForm_${serializeNum}"
                      data-bv-submitButtons="#editFormSubmitBtn_${serializeNum}"
                      data-bv-message="This value is not valid"
                      data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
                      data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
                      data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
                    <input type="hidden" name="id" value="${editEntity.id}">
                    <input type="hidden" name="type" value="1">
                    <input type="hidden" name="isBlockUp"  value="${editEntity.isBlockUp}">
                    <#if (true && editModel=='add')||(true && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20 margin-top-30">
                            <div class="form-group">
                                <label for="name" class="col-sm-3 col-sm-offset-1 control-label no-padding-right"><span style="color: red">*</span>课时包名称：</label>
                                <div class="col-sm-6">
                                    <input data-bv-remote="true" data-bv-remote-url="tssPackageController/verificationPackageName.do?id=${editEntity.id}"
                                           data-bv-remote-message="课时包已存在！" required="required" data-bv-message="请输入课时包名称！"
                                           name="name" alt="课时包名称" id="name" placeholder="课时包名称" type="text" title="课时包名称" class="form-control"
                                           value="${editEntity.name}"/>
                                    <span class="text"></span>
                                    <small  class="help-block" style="color: red;text-align: left;font-size: 12px">（注：课时包命名示例：2017/标准版/96课时）</small>
                            </div>
                        </div>
                    </#if>
                    <#if (true && editModel=='add')||(true && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20">
                            <div class="form-group">
                                <label for="totalClassHour"
                                       class="col-sm-3 col-sm-offset-1 control-label no-padding-right"><span style="color: red">*</span>总课时数：</label>
                                <div class="col-sm-6">
                                    <label class="pull-left">
                                        <label>
                                            <input style="width:60px;height: 34px;" data-bv-integer-message="请输入数字" required="required"
                                                   data-bv-message="请输入总课时数" data-bv-integer="true" size="11"
                                                   name="totalClassHour" alt="亲子总课时数" id="totalClassHour" placeholder=""
                                                   type="text" title="亲子总课时数" class="form-control" onblur="getSumPrice(totalClassHour,this)"
                                                   value="${editEntity.totalClassHour}"/>
                                        </label>
                                        <label>
                                            &nbsp;&nbsp;课时
                                        </label>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </#if>

                    <#if (true && editModel=='add')||(true && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20">
                            <div class="form-group">
                                <label for="originalUnitPrice"
                                       class="col-sm-3 col-sm-offset-1 control-label no-padding-right"><span style="color: red">*</span>课时包原单价：</label>
                                <div class="col-sm-6">
                                    <input data-bv-integer="true" data-bv-message="请输入课时包总价" required="required"
                                           data-bv-integer-message="请输入数字" size="22" onblur="getSumPrice(originalUnitPrice,this)"
                                           name="originalUnitPrice" alt="课时包原单价" id="originalUnitPrice"
                                           placeholder="课时包原单价" type="text" title="课时包原单价" class="form-control"
                                           value="${editEntity.originalUnitPrice}"/>
                                    <span class="text"></span>
                                </div>
                            </div>
                        </div>
                    </#if>

                    <#if (true && editModel=='add')||(true && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20">
                            <div class="form-group">
                                <label for="sumPrice" class="col-sm-3 col-sm-offset-1 control-label no-padding-right"><span style="color: red">*</span>课时包总价：</label>
                                <div class="col-sm-6">
                                    <input data-bv-integer="true" data-bv-message="请输入课时包总价" required="required"
                                           data-bv-integer-message="请输入数字" name="sumPrice" readonly
                                           alt="课时包总价" id="sumPrice" placeholder="课时包总价" type="text" title="课时包总价"
                                           class="form-control" value="${editEntity.sumPrice}"/>
                                    <span class="text"></span>
                                </div>
                            </div>
                        </div>
                    </#if>

                    <#if (false && editModel=='add')||(false && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20">
                            <div class="form-group">
                                <label for="attendanceDay"
                                       class="col-sm-3 col-sm-offset-1 control-label no-padding-right"><span style="color: red">*</span>过渡可出勤天数</label>
                                <div class="col-sm-6">
                                    <input data-bv-integer-message="请输入数字" required="required"
                                           data-bv-message="请输入过渡可出勤天数" data-bv-integer="true" size="11"
                                           name="attendanceDay" alt="过渡可出勤天数" id="attendanceDay" placeholder="过渡可出勤天数"
                                           type="text" title="过渡可出勤天数" class="form-control"
                                           value="${editEntity.attendanceDay}"/>
                                    <span class="text"></span>
                                </div>
                            </div>
                        </div>
                    </#if>

                    <#if (true && editModel=='add')||(true && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20">
                            <div class="form-group">
                                <label for="validDate" class="col-sm-3 col-sm-offset-1 control-label no-padding-right"><span style="color: red">*</span>有效期：</label>
                                <div class="col-sm-6 ">
                                    <label class="pull-left">
                                        <label>
                                            <input style="width: 60px;height: 34px;" data-bv-integer-message="请输入数字" required="required"
                                                   data-bv-message="请输入有效期" data-bv-integer="true" size="11"
                                                   name="validDate" alt="有效期" id="validDate" placeholder="" type="text"
                                                   title="有效期" class="form-control" value="${editEntity.validDate}"/>
                                        </label>
                                        <label>
                                            &nbsp;&nbsp;月
                                        </label>
                                    </label>
                                </div>
                            </div>
                        </div>
                    </#if>

                    <#if (false && editModel=='add')||(false && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20">
                            <div class="form-group">
                                <label for="empId" class="col-sm-3 col-sm-offset-1 control-label no-padding-right">当前操作者Id</label>
                                <div class="col-sm-6">
                                    <input data-bv-message="The field is not valid" size="32" name="empId" alt="当前操作者Id"
                                           id="empId" placeholder="当前操作者Id" type="text" title="当前操作者Id"
                                           class="form-control" value="${editEntity.empId}"/>
                                    <span class="text"></span>
                                </div>
                            </div>
                        </div>
                    </#if>

                    <#if (false && editModel=='add')||(false && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20">
                            <div class="form-group">
                                <label for="createTime" class="col-sm-3 col-sm-offset-1 control-label no-padding-right">创建时间</label>
                                <div class="col-sm-6">
										<span class="input-icon icon-left">
											<input data-bv-date-format="YYYY-MM-DD hh:mm:ss"
                                                   data-bv-message="The field is not valid"
                                                   data-bv-date-message="请正确输入一个时间" data-bv-date="true" size="19"
                                                   name="createTime" alt="创建时间" id="createTime" placeholder="创建时间"
                                                   type="text" title="创建时间"
                                                   class="form-control form-control date-picker"
                                                   onfocus="WdatePicker({doubleCalendar:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                                                   value="${editEntity.createTime}"/>
											<i class="fa fa-calendar"></i>
										</span>
                                </div>
                            </div>
                        </div>
                    </#if>
                    <#if (false && editModel=='add')||(false && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20">
                            <div class="form-group">
                                <label for="updateTime" class="col-sm-3 col-sm-offset-1 control-label no-padding-right">赠课范围</label>
                                <div class="col-sm-6">
										<span class="input-icon icon-left">
											<input data-bv-date-format="YYYY-MM-DD hh:mm:ss"
                                                   data-bv-message="The field is not valid"
                                                   data-bv-date-message="请正确输入一个时间" data-bv-date="true" size="19"
                                                   name="updateTime" alt="赠课范围" id="updateTime" placeholder="赠课范围"
                                                   type="text" title="赠课范围"
                                                   class="form-control form-control date-picker"
                                                   onfocus="WdatePicker({doubleCalendar:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                                                   value="${editEntity.updateTime}"/>
											<i class="fa fa-calendar"></i>
										</span>
                                </div>
                            </div>
                        </div>
                    </#if>
                    <#if (false && editModel=='add')||(false && editModel=='edit')>
                        <div class="col-xm-12 col-sm-12 col-lg-12 text-align-center margin-bottom-20">
                            <div class="form-group">
                                <label for="version" class="col-sm-3 col-sm-offset-1 control-label no-padding-right">版本</label>
                                <div class="col-sm-6">
                                    <input data-bv-integer-message="The field is number"
                                           data-bv-message="The field is not valid" data-bv-integer="true" size="11"
                                           name="version" alt="版本" id="version" placeholder="版本" type="text" title="版本"
                                           class="form-control" value="${editEntity.version}"/>
                                    <span class="text"></span>
                                </div>
                            </div>
                        </div>
                    </#if>
                    <div class="col-sm-12">
                        <div class="text-align-center ">
                            <button style="min-width: 80px;margin-right:20px;" type="submit" class="btn btn-blue" id="editFormSubmitBtn_${serializeNum}">确定
                            </button>
                            <button style="width: 80px" type="button" class="btn btn-blue" data-dismiss="modal">取消
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script src="assets/js/validation/bootstrapValidator_init.js"></script>
<script>
    $(".selectpicker_${serializeNum}").select2();

    var totalClassHourVal = 0;
    var originalUnitPriceVal = 0;
    function getSumPrice(type,that) {
        if(type == totalClassHour){
            totalClassHourVal = $(that).val();
        }
        if(type == originalUnitPrice){
            originalUnitPriceVal = $(that).val();
        }
        if(totalClassHourVal != 0 && originalUnitPriceVal != 0){
            $("#sumPrice").val(totalClassHourVal * originalUnitPriceVal);
        }
    }


    $("#editForm_${serializeNum}").bind("ajaxSubmitCallback", function (event, result) {
        if (result.resCode == 200) {
            bootbox.hideAll();
            logger.info(result.resMsg, true);
            toView('tssPackageController/tssPackageList.do?type=1',true,'POST',{pageSize:10})
        } else {
            logger.error(result.resMsg);
        }
    });
</script>